package boun.swe.bob.util;

import java.util.Random;

/**
 * This class is used for generating random passwords
 */
public class RandomPassword {

    
    private static final String charset = "0123456789abcdefghijklmnopqrstuvwxyz";

    /**
     * Creates a random password
     *
     * @param length indicates the desired length of a random password
     * @return random generated password
     */
    public static String getRandomString(int length) {
        Random rand = new Random(System.currentTimeMillis());
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int pos = rand.nextInt(charset.length());
            sb.append(charset.charAt(pos));
        }
        return sb.toString();
    }

}

